#ifndef DOWNLOADTABLE_H
#define DOWNLOADTABLE_H

#include <QWidget>
#include <QStringList>
#include <QTableView>
#include <QProgressBar>
#include "downloadtask.h"

class DownloadTable : public QWidget
{
    Q_OBJECT
public:
    explicit DownloadTable(QString dbTableName, QStringList dbTableColumn, QStringList dbTableColumnType,
                           QWidget *parent = 0);

    int rowCount();
    void addRow(DownloadTask *task);

    int progressForTask(int taskIndex);
    int priorityForTask(int taskIndex);
    
signals:
    void dataChanged();
    
public slots:
    void taskProgressChanged(QString fileName, int progress);

private:
    QString dbTableName;
    QStringList dbTableColumn;
    QStringList dbTableColumnType;
    QList<int> dbTableColumnW;
    QTableView *table;

    QString getCreateDownloadTableQuery();
    QString getInsertQuery(QString rename, QString savePath, double percent, int priority);
};

#endif // DOWNLOADTABLE_H
